""" 
For floating point arguments, the length of the result is ceil((stop -
start)/step).  This rule may result in the last element of the result
being greater than stop.
 """
from common import *

import pylab

def arangeFunc(in_start, in_stop, in_step, out_result):
    start = in_start()
    stop = in_stop()
    step = in_step()

    out_result(pylab.arange(start,stop,step))
    
    # send new set on every change.
    while True:
        
        alt = Alternation([{
                    in_start:None,
                    in_stop:None,
                    in_step:None
                    }])
        (g,msg) = alt.select()
        if (g == in_start):
            start = msg
        elif (g == in_stop):
            stop = msg
        elif (g == in_step):
            step = msg
        
        out_result(pylab.arange(start,stop,step))
        
